package org.wwb.antbox.user.model.role.view;

import org.ant.commons.commons.enums.EnumTool;
import org.ant.commons.models.view.AbstractListView;
import org.wwb.antbox.user.model.role.entity.SysRole;
import org.wwb.antbox.user.model.role.enums.SysRoleStatusEnum;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author Bond
 * @Date: 19-8-19 10:43
 * @Description: 角色列表视图
 */
public class RoleListView extends AbstractListView<RoleListView, SysRole, String> {

    /** 角色Id, 数据库字段：id */
    private String key;

    /** 角色名称, 数据库字段：role_name */
    private String title;

    /** 排序, 数据库字段：role_sort */
    private Integer roleSort;

    /** 备注, 数据库字段：remark */
    private String remark;

    /** 角色状态 正常、停用, 数据库字段：role_status */
    private Boolean disabled;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(Integer roleSort) {
        this.roleSort = roleSort;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }


    public List<RoleListView> myListView(List<SysRole> entityList) {
        if (entityList == null) {
            return new ArrayList();
        } else {
            List<RoleListView> vList = new ArrayList(entityList.size());
            Iterator var3 = entityList.iterator();

            while(var3.hasNext()) {
                SysRole sysRole = (SysRole)var3.next();
                RoleListView roleListView = new RoleListView();
                roleListView.setKey(sysRole.getId());
                roleListView.setTitle(sysRole.getRoleName());
                roleListView.setRemark(sysRole.getRemark());

                SysRoleStatusEnum sysRoleStatusEnum = EnumTool.enumOf(SysRoleStatusEnum.class, "2");
                boolean disabled = sysRoleStatusEnum.getCode().equals(sysRole.getRoleStatus()) ? true : false;
                roleListView.setDisabled(disabled);
                vList.add(roleListView);
            }

            return vList;
        }
    }
}
